var app = getApp();
// pages/reply/finish/fihish.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    money:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      money:options.money,
      id: options.id
    })
  },

  collect:function(){
    var that = this;
    wx.showLoading({
      title: '收藏中...',
    });
    wx.request({
      url: app.globalData.phpUrl + 'Question/api',
      method:'POST',
      data: { api_name: 'collect', openid: app.globalData.userData.openOId, questionnaire_id: parseInt(that.data.id)},
      success:function(e){
        wx.hideLoading()
        if(e.data.code == 1){
          wx.showToast({
            title: '收藏成功!',
          })
        }else{
          wx.showToast({
            image:'../../../images/attend.png',
            title: '收藏失败!',
          })
        }
      }
    })
  },

  viewMoney:function(){
    wx.switchTab({
      url: '../../mine/mine',
    })
  },

  moreMoney:function(){
    wx.switchTab({
      url: '../../index/index',
    })
  },

  onShareAppMessage: function (e) {
    var that =this;
    var serName = '您的朋友';
    if (app.globalData.userInfo.nickName) {
      serName = app.globalData.userInfo.nickName
    }
    return {
      title: serName + '邀请你来答题抢红包!',
      imageUrl: '../../../images/shareImg.png',
      path: 'pages/reply/reply?id=' + that.data.id + '&article=true'
    }
  }
})